home *** CD-ROM | disk | FTP | other *** search
/ NT Sources / Infomagic - NT Source Volume 1 (Disc 2 of 2).iso / utils / sdisetup.exe / sdi_js.txt < prev    next >
Text File  |  1998-05-31  |  2KB  |  104 lines

  1. //    This file contains a JavaScript object called SDI which contains
  2. //    functions to manipulate SDI using its automation interfaces.  This
  3. //    file is only an example and does not implement everything SDI can
  4. //    do.  The end of this file contains a very brief sample of using
  5. //    the SDI object.  This sample was written and tested using
  6. //    Microsofts Windows Scripting Host which can be found at the 
  7. //    following location:  http://www.microsoft.com/scripting
  8.  
  9.  
  10. function SDI()
  11.     {
  12.     this.objSDI = WScript.CreateObject("SDI32.Application");
  13.     this.ftpconnect=ftpconnect;
  14.     this.ftpput=ftpput;
  15.     this.ftpget=ftpget;
  16.  
  17.     this.ftpbinary=ftpbinary;
  18.     this.ftpascii=ftpascii;
  19.  
  20.     this.ftpdisconnect=ftpdisconnect;
  21.     this.displayerror=displayerror;
  22.     }
  23.  
  24. function ftpconnect(strServer,strUsername,strPassword)
  25.     {
  26.  
  27.     if(this.objSDI.ftp("open",strServer)==false)
  28.         return false;
  29.  
  30.     if(this.objSDI.ftp("username",strUsername)==false)
  31.         return false;
  32.  
  33.     if(this.objSDI.ftp("password",strPassword)==false)
  34.         return false;
  35.  
  36.     return true;
  37.     }
  38.  
  39. function ftpput(strLocalFile,strRemoteFile)
  40.     {
  41.     if(this.objSDI.ftp("remotepath",strRemoteFile)==false)
  42.         return false;
  43.  
  44.     if(this.objSDI.ftp("put",strLocalFile)==false)
  45.         return false;
  46.     }
  47.  
  48. function ftpget(strRemoteFile,strLocalFile)
  49. {
  50.     if(this.objSDI.ftp("localpath",strLocalFile)==false)
  51.         return false;
  52.  
  53.     if(this.objSDI.ftp("get",strRemoteFile)==false)
  54.         return false;
  55.  
  56.     return true;
  57.     }
  58.  
  59. function ftpbinary()
  60.     {
  61.     if(this.objSDI.ftp("binary","")==false)
  62.         return false;
  63.     else
  64.         return true;
  65.     }
  66.  
  67. function ftpascii()
  68.     {
  69.     if(this.objSDI.ftp("ascii","")==false)
  70.         return false;
  71.     else
  72.         return true;
  73.     }
  74.  
  75. function ftpdisconnect()
  76.     {
  77.     if(this.objSDI.ftp("close","")==false)
  78.         return false;
  79.     else
  80.         return true;
  81.     }
  82.  
  83. function displayerror()
  84.     {
  85.     var objShell = WScript.CreateObject("WScript.Shell");
  86.     objShell.Popup(this.objSDI.GetLastError());
  87.     }
  88.  
  89.  
  90.  
  91.  
  92. //    This is a brief sample of using the SDI object
  93.  
  94. var vSDI = new SDI();
  95. if((vSDI.ftpconnect("ftp.testserver.com","anonymous","user@testserver.com"))==false)
  96.     vSDI.displayerror();
  97.  
  98. if((vSDI.ftpget("/index","c:\\temp\\index.txt"))==false)
  99.     vSDI.displayerror();
  100.     
  101. vSDI.ftpdisconnect();
  102.  
  103.  
  104.